import axios from "axios"

const http = axios.create({
    baseURL: "http://shop.bluej.cn/api",
    timeout: 5000
})

export const post = (url, data) => {
    return new Promise((resolve, reject) => {
        http.post(url, data, {
            headers: {
                "Content-Type": "application/json"
            }
        }).then((res) => {
            resolve(res.data)
        })
            .catch(err => { reject(err) })
    })
}


export const get = (url) => {
    return new Promise((resolve, reject) => {
        http.get(url, {
            headers: {
                "Content-Type": "application/json"
            }
        }).then((res) => {
            resolve(res.data)
        })
            .catch(err => { reject(err) })
    })
}
sessionStorage.getItem("token")
console.log("token");
export const posttoken = (url, data) => {
    return new Promise((resolve, reject) => {
        http.posttoken(url, data, {
            headers: {
                "Content-Type": "application/json",
                "x-token": token,
            }
        }).then((res) => {
            resolve(res.data)
        })
            .catch(err => { reject(err) })
    })
}